﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.inspectioninfos
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int inspinfo_id=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(inspinfo_id);
				}
			}
		}
			
	private void ShowInfo(int inspinfo_id)
	{
		lcs.BLL.inspectioninfos bll=new lcs.BLL.inspectioninfos();
		lcs.Model.inspectioninfos model=bll.GetModel(inspinfo_id);
		this.lblinspinfo_id.Text=model.inspinfo_id.ToString();
		this.txtsubmitUid.Text=model.submitUid.ToString();
		this.txtout_storage_detail_Id.Text=model.out_storage_detail_Id.ToString();
		this.txtinspectioninfo.Text=model.inspectioninfo.ToString();
		this.txtsubmitTime.Text=model.submitTime.ToString();
		this.txtinspection_id.Text=model.inspection_id.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtsubmitUid.Text))
			{
				strErr+="提交人格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtout_storage_detail_Id.Text))
			{
				strErr+="巡检物料ID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtinspectioninfo.Text))
			{
				strErr+="0正常1有问题格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtsubmitTime.Text))
			{
				strErr+="提交时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtinspection_id.Text))
			{
				strErr+="如有问题处理表ID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int inspinfo_id=int.Parse(this.lblinspinfo_id.Text);
			int submitUid=int.Parse(this.txtsubmitUid.Text);
			int out_storage_detail_Id=int.Parse(this.txtout_storage_detail_Id.Text);
			int inspectioninfo=int.Parse(this.txtinspectioninfo.Text);
			DateTime submitTime=DateTime.Parse(this.txtsubmitTime.Text);
			int inspection_id=int.Parse(this.txtinspection_id.Text);


			lcs.Model.inspectioninfos model=new lcs.Model.inspectioninfos();
			model.inspinfo_id=inspinfo_id;
			model.submitUid=submitUid;
			model.out_storage_detail_Id=out_storage_detail_Id;
			model.inspectioninfo=inspectioninfo;
			model.submitTime=submitTime;
			model.inspection_id=inspection_id;

			lcs.BLL.inspectioninfos bll=new lcs.BLL.inspectioninfos();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
